<?php


// This is template file for psa_request_info_html() function. 
// See PSA manual for details.


?>
<!-- PSA_REQUEST_INFO:START -->
<script type="text/javascript">
	
	var psa_rqi_obj_visible = {};
	
	// show or hide element
	function psa_rqi_sh(elementId,do_return,dont_remember) {
		if(elementId && elementId != ''){
			if(obj = document.getElementById(elementId)) {
				if(obj.style.display != 'none'){
					obj.style.display = 'none';
					if(!dont_remember){
						psa_rqi_obj_visible[elementId] = 0;
						psa_rqi_write_cookie('psa_request_info_open','');
					}
					if(do_return)
						return 0;
				}
				else{
					obj.style.display='block';
					if(!dont_remember){
						psa_rqi_obj_visible[elementId] = 1;
						psa_rqi_write_cookie('psa_request_info_open',elementId);
					}
					if(do_return)
						return 1;
				}
			}
		}
	}
	
	// hide all elements in objects except elementId
	function psa_rqi_sh_all(elementId) {
		
		psa_rqi_obj_visible[elementId] = psa_rqi_sh(elementId,true);
		
		for(i in psa_rqi_obj_visible){
			if(i != elementId){
				document.getElementById(i).style.display = 'none';
			}
		}
	}
	
	// A function to write a value to a cookie. The hours parameter is optional
	function psa_rqi_write_cookie(name, value, hours){
		var expire = "";
		if(hours != null){
			expire = new Date((new Date()).getTime() + hours * 3600000);
			expire = "; expires=" + expire.toGMTString();
		}
		document.cookie = name + "=" + escape(value) + expire + '; path=/;';
	}
	
	// A function that returns the value of a cookie given the cookie name.
	function psa_rqi_read_cookie(name){
		var cookieValue = "";
		var search = name + "=";
		if(document.cookie.length > 0){ 
			offset = document.cookie.indexOf(search);
			if (offset != -1){ 
				offset += search.length;
				end = document.cookie.indexOf(";", offset);
				if (end == -1) end = document.cookie.length;
				cookieValue = unescape(document.cookie.substring(offset, end))
			}
		}
		return cookieValue;
	}
	
	// hide or show all
	function psa_rqi_sh_com() {
		var state = psa_rqi_sh('psa_rqi_shcom',1,1);
		psa_rqi_write_cookie('psa_request_info_all',state);
		psa_rqi_sh_com_link(state);
	}
	
	// hide or show all link text change
	function psa_rqi_sh_com_link(on_off) {
		if(on_off == 1)
			document.getElementById('psa_rqi_showhide_all').innerHTML = 'Hide RI';
		else
			document.getElementById('psa_rqi_showhide_all').innerHTML = 'Show RI';
	}

	
</script>
<div style="margin-top:20px;">
<span style="font-size:8pt;">&nbsp;&nbsp;<a href="javascript:psa_rqi_sh_com();"><span id="psa_rqi_showhide_all"></span></a></span>
	<div id="psa_rqi_shcom" style="background-color:#F3F3F3;font-size:8pt;font-family:Arial;padding-bottom:30px;z-index:10001;position:relative;">
		<!-- menu -->
		<div style="font-weight:bold;background-color:#CCCCCC;margin:5px;padding:5px;">
			<a href="javascript:psa_rqi_sh_all('psa_rqi_exe_plugins')">Executed plugins</a> |
			<?php foreach ($objects as $key => $value){ ?>
			<a href="javascript:psa_rqi_sh_all('psa_rqi_obj_<?php echo $key ; ?>');"><?php echo $value['menu_text']; ?></a> | 
			<?php } ?>
			<?php if(isset($log)){ ?><a href="javascript:psa_rqi_sh_all('psa_rqi_log');">Log</a> | <?php } ?><?php if(isset($log_profile)){ ?><a href="javascript:psa_rqi_sh_all('psa_rqi_profile_log');">Profile log</a><?php } ?>
		</div>
		
		<div style="white-space:nowrap;margin-left:20px">
			
			<!-- Executed plugins -->
			<div id="psa_rqi_exe_plugins" style="display:none;">
				<b>Executed plugins</b><hr />
				<table border="0" cellpadding="2" cellspacing="0">
					<?php foreach ($executed_plugins as $key => $value){ ?>
					<tr>
						<td valign="top"><b><?php echo $key + 1; ?></b>&nbsp;</td>
						<td valign="top">
							<?php echo $value[0]; ?> -> <?php echo $value[1]; ?> (<?php if($value[2]){ ?><a href="javascript:psa_rqi_sh('psa_rqi_args_<?php echo $key ; ?>',false,true)">args</a><?php }else{ ?>&nbsp;<?php } ?>)
							<?php if($value[2]){ ?>
							<div id="psa_rqi_args_<?php echo $key ; ?>" style="display:none;background-color:#FFFFFF"><pre><?php echo htmlspecialchars(substr_replace(substr_replace(print_r($value[2],true), '', 0, 7),'',-2)); ?></pre></div>
							<?php } ?>					</td>
						<td valign="top">&nbsp;[<?php echo str_replace('Psa_Plugin_','',$value[3]); ?>]&nbsp;</td>
						<td valign="top"><?php echo $value[4]; ?></td>
						<td valign="top">&nbsp;<a href="javascript:psa_rqi_sh('psa_rqi_result_<?php echo $key ; ?>',false,true)">Psa_Result</a>&nbsp;<?php if($value[6] == 'res_before'){ ?>(before method call)<?php } ?>
							<div id="psa_rqi_result_<?php echo $key ; ?>" style="display:none;background-color:#FFFFFF"><pre><?php echo htmlspecialchars($value[5]); ?></pre></div>
						</td>
					</tr>
					<?php } ?>
				</table>
			</div>
			
			<!-- $psa_result | $_GET | $_POST | $_SESSION | $_COOKIE | $_SERVER | $PSA_CFG | $psa_plugins  -->
			<?php foreach ($objects as $key => $value){ ?>
			<div id="psa_rqi_obj_<?php echo $key ; ?>" style="display:none;">
				<b><?php echo $value['menu_text']; ?></b><hr />
				<pre><?php echo htmlspecialchars(print_r($value['content'],true)); ?></pre>
			</div>
			<?php } ?>
			
			<!-- log -->
			<?php if(isset($log)){ ?>
			<div id="psa_rqi_log" style="display:none;">
				<b>Psa Log:</b><hr />
				<pre><?php echo htmlspecialchars(print_r($log,true)); ?></pre>
			</div>
			<?php } ?>
			
			<!-- Profile log -->
			<?php if(isset($log_profile)){ ?>
			<div id="psa_rqi_profile_log" style="display:none;">
				<b>Profile log:</b><hr />
				<pre><?php foreach ($log_profile as $key => $value){ ?><?php echo $value['method'] ?>() [<?php echo round($value['total_time'], 4) ?> s]<br /><?php } ?></pre>
			</div>
			<?php } ?>
		</div>
	</div>
</div>

<script type="text/javascript">
	
	// open previously open menus
	psa_rqi_sh(psa_rqi_read_cookie('psa_request_info_open'));
	
	if(psa_rqi_read_cookie('psa_request_info_all') == 1){
		document.getElementById('psa_rqi_shcom').style.display = 'block';
		psa_rqi_sh_com_link(1);
	}
	else{
		document.getElementById('psa_rqi_shcom').style.display = 'none';
		psa_rqi_sh_com_link(0);
	}

</script>
<!-- PSA_REQUEST_INFO:END -->
